package com.karaoke.android.newok

import android.content.Context
import android.media.AudioManager
import android.provider.Settings
import com.facebook.drawee.backends.pipeline.Fresco
import com.github.johnkil.print.PrintConfig
import com.joanzapata.iconify.Iconify
import com.karaoke.android.data.app
import com.karaoke.android.library.BaseApp
import com.karaoke.android.player.VideoManager
import com.karaoke.android.style.IconModule
import com.orhanobut.hawk.Hawk
import com.stericson.RootShell.RootShell
import io.realm.Realm
import io.realm.RealmConfiguration
import org.acra.ACRA
import org.acra.ReportField
import org.acra.annotation.ReportsCrashes
import org.acra.sender.HttpSender

/**
 * Created by allen on 2017/4/21.
 */

@ReportsCrashes(
        httpMethod = HttpSender.Method.POST,
        reportType = HttpSender.Type.JSON,
        formUri = "http://main.oksrv.com/api/report/deviceReport",
        customReportContent = arrayOf(
                ReportField.STACK_TRACE,
                ReportField.CUSTOM_DATA)
               )
class NewokApplication : BaseApp()
{
    override fun onCreate()
    {
        super.onCreate()
        RootShell.isAccessGiven()
        app = this
        Settings.System.putInt(contentResolver, Settings.System.SOUND_EFFECTS_ENABLED, 0)
        val audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 15, 0)
        Fresco.initialize(this)
        PrintConfig.initDefault(assets, "font/iconfont.ttf")
        Iconify.with(IconModule())
        Hawk.init(this).build()
        Realm.init(this)
        val realmConfig = RealmConfiguration.Builder()
                .schemaVersion(1000)
                .deleteRealmIfMigrationNeeded()
                .build()
        Realm.setDefaultConfiguration(realmConfig)
        VideoManager.initialize(this)
        ACRA.init(this)
    }


}
